#include<bits/stdc++.h>
using namespace std;
const int N=3000010;
int n;
char s[N];
bool f[21][1<<20];
int ans;
void dfs(int n,int s){
    if(f[n][s])return;
    f[n][s]=1;
    ans++;
    for(int i=1;i<n;i++){
        if(((s>>(i-1))&1)==0&&((s>>i)&1)==1)continue;
        int t=(s&(((1<<(i-1))-1)))|((s&((1<<n)-(1<<(i+1))))>>2);
        dfs(n-2,t);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);
    cin>>s+1;
    n=strlen(s+1);
    if(n>20){
        if(s[1]=='A')cout<<(n+1)/2;
        else cout<<n/2+1;
        return 0;
    }
    int ss=0;
    for(int i=1;i<=n;i++)if(s[i]=='B')ss|=1<<(i-1);
    dfs(n,ss);
    cout<<ans;
    return 0;
}
